<?php
/**
* @file adstatistic.php
* @date: 2015-12-10 下午4:49:10
* @author: xiweijie
*/
namespace haibao\app\data;

class AdStatistic extends \haibao\app\data\BaseMysql{

	public function __construct(){
		parent::__construct('\haibao\app\model\data\AdStatistic');
	}
	
	public function getBmsStatisticBy($starDate,$endDate,$adIds){
		$result = array();
		$sql = 'select ad_id,zone_id,impressions,clicks,date_time from phpads_data_summary_ad_hourly';
		$sql .= ' where date_time >= "'.$starDate.'" and date_time < "'.$endDate.'" and ad_id in ('.implode(',', $adIds).')';
		$this->setConfig( \haibao\classlibrary\www\Config::CLASSLIBRARY_CONFIG_MYSQL_NEW_ADV_UTF8 );
		$data = $this->query($sql);
		$i=0;
		while($data->fetch_assoc()){
			$result[$i]['AdId'] = $data->getData('ad_id');
			$result[$i]['ZoneId'] = $data->getData('zone_id');
			$result[$i]['Date'] = $data->getData('date_time');
			$result[$i]['PV'] = $data->getData('impressions');
			$result[$i]['CK'] = $data->getData('clicks');
			$i++;
		}
		return $result;
	}
}